'use strict';

const Controller = require('egg').Controller;

class HttpController extends Controller {
  async get() {
    const  ctx  = this.ctx;
    const result = await ctx.service.http.getall('table_http')
    ctx.body = result;
  }
  async post() {
    const  ctx  = this.ctx;
    const result = await ctx.service.public.add('table_http',ctx.query)
    await ctx.service.public.add('table_info',{http_id:result.insertId})
    await ctx.service.public.add('table_foot',{http_id:result.insertId})
    await ctx.service.public.add('table_gg',{http_id:result.insertId})
    ctx.body = result;
  }
  async put() {
    const  ctx  = this.ctx;
    const result = await ctx.service.public.update('table_http',ctx.query)
    ctx.body = result;
  }
  async delete() {
    const  ctx  = this.ctx;
    const result = await ctx.service.public.delete('table_http',ctx.query)
    ctx.body = result;
  }
}

module.exports = HttpController;
